<script type="text/javascript" src="/assets/public/jquery/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="/assets/public/layermobile/layer.js"></script>
<script src="/assets/base/restaurant/js/handlebars-v3.0.3.js"></script>
<script type="text/javascript" src="/assets/public/defaultalert/default_alert.js"></script>

<script type="text/javascript">
    //一些公用的函数
    window.fm = {};
    fm.alert = function (msg, style, time, end) { //layer  alert  弹出提示 2秒后自动关闭
        layer.closeAll();
        layer.open({
            content: msg,
            style: style || 'background-color:#2db07e; text-align:center;color:#fff; border:none; font-size:2vw;padding: 2vw 3vw;',
            time: time || 1,
            end: end || function () {

            }
        });
    };

    fm.confirm = function (msg,callback) {
        layer.closeAll();
        layer.open({
            content: msg,
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function(){
                callback(1);
            }, no: function(){
                callback(0);
            }
        });
    };

    fm.showLoging = function (text,loadTime) { //显示加载中
        layer.closeAll();
        var logIndex = layer.open({
            type: 2,
            shadeClose: false,
            content: text || '加载中...'
        });

        if (!loadTime) {
            loadTime = 15000;
        }
        setTimeout(function () {
            layer.close(logIndex);
        }, loadTime);
    }

    fm.closeLayer = function (times) { //关闭加载中
        if (times) {
            setTimeout(function () {
                layer.closeAll();
            }, times * 500);
        } else {
            layer.closeAll();
        }
    }

</script>
